package com.fjec.market.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.market.entity.InfoPurchase;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 006.采购商表 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2020-09-07
 */
public interface InfoPurchaseMapper extends BaseMapper<InfoPurchase> {
    List<InfoPurchase> getInfoPurchaseByMarkCode(@Param("markCode") Integer markCode, Page page);

    @SelectProvider(type = com.fjec.market.mapper.sqlbuilder.PurchaseSqlBuilder.class, method = "getPurchasesByPurchaseIdsAndMarkCode")
    List<InfoPurchase> getPurchasesByPurchaseIdsAndMarkCode(@Param("markCode") int markCode, @Param("purchaseIds") List<Long> purchaseIds, Page page);

    /**
     * 获取需要生成shopNum的采购商列表
     *
     * @param limit
     * @return
     */
    List<InfoPurchase> getPurchaseForShopNumGen(@Param("limit") int limit,
                                                @Param("minutes") int minutes);

    /**
     * 统计采购商数据
     *
     * @param startTime
     * @return
     */
    List<Map<String, Object>> statPurchaseData(@Param("startTime") LocalDateTime startTime,
                                               @Param("endTime") LocalDateTime endTime);

    List<InfoPurchase> getPurchaseByShopNumAndMarkCode(@Param("markCode") int markCode, @Param("shopNum") Long shopNum);

    /**
     * 临时定时更新店铺排序
     *
     * @return
     */
    Long tmpUpdateWeight(@Param("num") Integer num);
}
